<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp"%>
<%@ include file="/WEB-INF/common/header.jsp"%>

	<div class="layui-fluid">

		<form class="layui-form" isLoad="${empty bean ? 0 : 1}">
		  
		<c:if test="${not empty bean }">
		  <div class="layui-form-item">
		    <label class="layui-form-label">主键：</label>
		    <div class="layui-input-block">
		    	<div class="layui-form-mid layui-word-aux">${bean.id }</div>
		      	<input type="hidden" name="id" />
		    </div>
		  </div>
		  
		  <hr>
		</c:if>
		  
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">模板标题：</label>
		    <div class="layui-input-inline">
		    	<input type="text" name="title" required lay-verType="tips" lay-verify="required" placeholder="请输入微信模板标题" autocomplete="off" class="layui-input" maxlength="20" style="width:200px;" />
		    </div>
		  </div>
		  
		  <hr>
		  
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">微信模板：</label>
		    <div class="layui-input-inline">
		    	<input type="text" name="templateCode" required lay-verType="tips" lay-verify="required" placeholder="请输入微信模板ID" autocomplete="off" class="layui-input" maxlength="100" style="width:420px;" />
		    </div>
		  </div>
		  
		  <hr>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">模板类型：</label>
		    <div class="layui-input-inline">
		      <c:choose>
		      	<c:when test="${type == 0 }">
		      		<div class="layui-form-mid layui-word-aux">公众号模板</div>
		      		<input type="hidden" name="type" />
		      	</c:when>
		      	<c:otherwise>
		      		<div class="layui-form-mid layui-word-aux">小程序模板</div>
		      		<input type="hidden" name="type" />
		      	</c:otherwise>
		      </c:choose>
		    </div>
		    
		    <label class="layui-form-label">状态：</label>
		    <div class="layui-input-inline">
		      <c:choose>
	    		<c:when test="${not empty bean }">
	    			<input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" value="0" {{bean.status == 0 'checked' : ''}} />
	    		</c:when>
	    		<c:otherwise>
	    			<input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" value="0" checked />
	    		</c:otherwise>
		      </c:choose>
		    </div>
		  </div>
		  
		  <hr/>
		  
		  <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">跳转逻辑：</label>
		    	<c:set var="jumpFlag" value="0" />
		    	<c:choose>
				  	<c:when test="${(bean.url == null || bean.url == '') && (bean.page == null || bean.page == '') }">
				  		<c:set var="jumpFlag" value="0" />
				  	</c:when>
				  	<c:otherwise>
				  		<c:choose>
				  			<c:when test="${bean.page != null && bean.page != ''  }">
				  				<c:set var="jumpFlag" value="2" />
				  			</c:when>
				  			<c:otherwise>
				  				<c:set var="jumpFlag" value="1" />
				  			</c:otherwise>
				  		</c:choose>
				  	</c:otherwise>
				  </c:choose>
		      <c:choose>
		      
		      	<c:when test="${type == 0 }">
		      		<div class="layui-input-inline" style="width:120px;">
			      		<select class="layui-form" lay-filter="selectToType">
			      			<option value="" ${jumpFlag == 0 ? 'selected' : ''}>不跳转</option>
			      			<option value="1" ${jumpFlag == 1 ? 'selected' : ''}>跳转网页</option>
			      			<option value="2" ${jumpFlag == 2 ? 'selected' : ''}>跳转小程序</option>
			      		</select>
		      		</div>
		      		
		      		<div class="layui-input-inline">
		      			<input type="text" id="_url" name="url" placeholder="公众号推送消息时跳转url地址" autocomplete="off" class="layui-input" style="width:300px;${jumpFlag != 1 ? 'display:none;' : ''}" />
		      			<input type="text" id="_page" name="page" placeholder="公众号推送消息时跳转小程序页面" autocomplete="off" class="layui-input" style="width:300px;${jumpFlag != 2 ? 'display:none;' : ''}" />
				    </div>
		      	</c:when>
		      	<c:otherwise>
		      		<div class="layui-input-inline">
		     			<input type="text" name="page" placeholder="小程序推送消息时跳转页面" autocomplete="off" class="layui-input" maxlength="32" style="width:400px;" />
		      		</div>
		      	</c:otherwise>
		      </c:choose>
		  </div>
		  
		  <hr/>
		  
		  <div class="layui-form-item">
		    <label class="layui-form-label">模板通道：</label>
		    <div class="layui-input-inline">
		    	<c:choose>
			      	<c:when test="${type == 0 }">
				    	<select name="appid" class="fsSelect fsDict" isLoad="1" dict="wxConfigList0" addNull="1" lay-verify="required"></select>
			      	</c:when>
			      	<c:otherwise>
			      		<select name="appid" class="fsSelect fsDict" isLoad="1" dict="wxConfigList1" addNull="1" lay-verify="required"></select>
			      	</c:otherwise>
				</c:choose>
		    </div>
		  </div>
		  
		  <hr/>
		  
		  <div class="layui-form-item" style="text-align: center;">
		  	 <button class="layui-btn" lay-submit="" lay-filter="${empty bean ? 'save' : 'edit' }" url="${ctx }/wx/temp/add"><i class="layui-icon">&#xe642;</i>${empty bean ? '新增' : '编辑' }</button>
	     	 <button type="button" class="layui-btn layui-btn-primary" function="close">关闭</button>
	   	  </div>
	  
		</form>
	</div>
	
	<script type="text/javascript">
		layui.use('form', function(){
			var form = layui.form;
		  	form.on('select(selectToType)', function(data){
				var val = data.value;
				$("#_url").hide();
				$("#_page").hide();
				if (val == 1){
					$("#_url").show();
				}
				else if (val == 2){
					$("#_page").show();
				}
			});
		});
	</script>
<%@ include file="/WEB-INF/common/bottom.jsp"%>